home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / owldlgs.zip / DLGMODAL.CPP < prev    next >
C/C++ Source or Header  |  1993-04-08  |  3KB  |  68 lines

  1. /**********************************************************************/
  2. /*                  Dlgmodal.cpp by Bob Bourbonnais                   */
  3. /*              released to the public domain 12/12/91                */
  4. /*              This program demonstrates a dialog box                */
  5. /*             with a menu and two buttons that can call              */
  6. /*          a modal dialog box from either the menu or a button.      */
  7. /*          A modal dialog box will not let you do anything in        */
  8. /*          the current program window until it is delt with.         */
  9. /*          You can change windows and do something in another        */
  10. /*           program when a normal model dialog box is open.          */
  11. /*          To force all programs to wait for a model dialog          */
  12. /*           make it system modal.  Refer to the system modal         */
  13. /*                     dialog program for an example.                 */
  14. /**********************************************************************/
  15. #include <owl.h>
  16. #include <dialog.h>
  17. #include "dlgmodal.h"
  18.  
  19. class TDialog2Dialog : public TDialog    // Dialog class to add
  20.   {                     // processing for menu and
  21.   public:                 // button selections
  22.     TDialog2Dialog(LPSTR lpName)         // constructor calls
  23.       :TDialog(NULL,lpName) {};         // base class constructor
  24.     virtual void HandleMenuItem(RTMessage Msg)      // menu handler
  25.       = [CM_FIRST + IDM_MODAL_DIALOG];
  26.     virtual void HandleButtonMessage(RTMessage Msg) // button handler
  27.       = [ID_FIRST + IDB_MODAL_DIALOG];   // close button handled by
  28.   };                                     // base class button handler
  29. void TDialog2Dialog:: HandleMenuItem(RTMessage)
  30.   {
  31.   GetApplication()->ExecDialog(new TDialog(this,"Modal_Dialog_Box"));
  32.   }               //ExecDialog activates a modal dialog box
  33. void TDialog2Dialog:: HandleButtonMessage(RTMessage)
  34.   {
  35.   GetApplication()->ExecDialog(new TDialog(this,"Modal_Dialog_Box"));
  36.   }
  37.  
  38. class TDialog2App : public TApplication  // Application Class to contain
  39.   {                                      // the application
  40.   public:
  41.     TDialog2App(LPSTR lpName, HANDLE hInstance,  // constructor calls the
  42.         HANDLE hPrevInstance,            // base class constructor
  43.         LPSTR lpCmdLine, int nCmdShow)
  44.         :TApplication(lpName, hInstance,
  45.                   hPrevInstance,
  46.                   lpCmdLine, nCmdShow) {};
  47.  
  48.     virtual void InitMainWindow(); // overrides base class InitMainWindow
  49.   };
  50.  
  51. void TDialog2App::InitMainWindow() // to initialize a dialog box
  52.   {                                // as the main window
  53.   MainWindow = new TDialog2Dialog("Main_Window_Dialog");
  54.   }                                // using message processing provided
  55.                    // by derived class
  56.  
  57. int PASCAL WinMain(HANDLE hInstance,              // main entry point from
  58.            HANDLE hPrevInstance,          // windows to this program
  59.            LPSTR lpCmdLine , int nCmdShow)
  60.   {
  61.   TDialog2App Dialog2("Dialog Tester",hInstance,  // create instance of
  62.                hPrevInstance,             // the dialog application
  63.                lpCmdLine,nCmdShow);
  64.   Dialog2.Run();                                  // run it
  65.   return (Dialog2.Status);                        // exit
  66.   }
  67. /**********************************************************************/
  68.